<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>设备使用管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        $(document).ready(function() {
            layui.use(['laypage', 'form','table'], function(){
                  var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
                  form.render();
                  var table = layui.table;
                  table.init('contentTable',{
                      cellMinWidth: 80,
                      limit: 30,
                      page: true
                      }
                  );
                  var laypage = layui.laypage;
                  laypage.render({
                      elem: 'layui-table-page1',
                      count: ${page.count}, //数据总数，从服务端得到
                      curr: ${page.pageNo},
                      limit:30,
                      layout: ['prev', 'page', 'next', 'count'],
                      jump: function(obj, first){
                        //首次不执行
                        if(!first){
                            $("#firstPage").val(false);
                            page(obj.curr,obj.limit);
                        }
                      }
                    });
                  
            }); 
        });
        function page(n,s){
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }
	</script>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
		  <li class="layui-this"><a href="${ctx}/dvc/deviceUse/">设备使用列表</a></li>
	   </ul>
	</div>    
	<form:form id="searchForm" modelAttribute="deviceUse" action="${ctx}/dvc/deviceUse/" method="post" class="layui-form">
	   <blockquote class="layui-elem-quote quoteBox">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
			<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<div class="layui-inline"><label class="layui-form-label">设备名称：</label>
				<div class="layui-input-block">
					<form:input path="deviceName" htmlEscape="false" maxlength="64" class="layui-input"/>
				</div>
				</div>
				<div class="layui-inline"><label class="layui-form-label">归属部门：</label>
				<div class="layui-input-block">
					<sys:treeselect id="deviceOffice" name="deviceOffice.id" value="${deviceMana.deviceOffice.id}" labelName="deviceOffice.name" labelValue="${deviceMana.deviceOffice.name}"
						title="部门" url="/sys/office/treeData?type=2" cssClass="layui-input" allowClear="true" notAllowSelectParent="true"/>
				</div>
				</div>
			    <div class="layui-inline">
                    <input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询"/>
                </div>
				
		</blockquote>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable"  class="layui-table"  lay-filter="contentTable">
		<thead>
			<tr>
				<th lay-data="{field:'device_id'}">设备名称</th>
				<th lay-data="{field:'device_office'}">归属部门</th>
				<th lay-data="{field:'user'}">领用人</th>
				<th lay-data="{field:'device_use'}">设备用途</th>
				<th lay-data="{field:'device_borrow_date'}">领用日期</th>
				<th lay-data="{field:'device_back_date'}">归还日期</th>
				<th lay-data="{field:'device_borrow_status'}">归还状态</th>
				<shiro:hasPermission name="dvc:deviceUse:edit">
					<th lay-data="{field:'flag',minWidth:120,fixed:'right'}">操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="deviceUse">
			<tr>
				<td><a class="layui-blue" href="${ctx}/dvc/deviceInfo/detail?id=${deviceUse.deviceId}">
					${deviceUse.deviceName}
				</a></td>
				<td>
					${deviceUse.deviceOffice.name}
				</td>
				<td>
					${deviceUse.user.name}
				</td>
				<td>
					${deviceUse.deviceUse}
				</td>
				<td>
					<fmt:formatDate value="${deviceUse.borrowDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${deviceUse.backDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${fns:getDictLabel(deviceUse.borrowStatus, 'borrow_status', '')}
				</td>
				<shiro:hasPermission name="dvc:deviceUse:edit"><td>
				<c:if test="${deviceUse.borrowStatus == '1'}">
    				<a class="layui-btn layui-btn-xs" lay-event="edit" href="${ctx}/dvc/deviceUse/back?id=${deviceUse.id}" onclick="return confirmx('确认该设备已归还？', this.href)">确认归还</a>
    			</c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</body>
</html>